# 导包
import requests
import config


# 创建接口类
class GoodsAPI:
    # 初始化
    def __init__(self):
        self.url_list = config.BASE_URL + "/api/v1/category/all"
        self.url_list_goods = config.BASE_URL + "/api/v1/product/by_category?id={}"
        self.url_goods = config.BASE_URL + "/api/v1/product/{}"

    # 获取商品分类
    def get_goods_list(self):
        return requests.get(self.url_list)

    # 获取分类下的商品
    def get_goods_under_list(self, theme_id):
        return requests.get(self.url_list_goods.format(theme_id))

    # 获取商品详情
    def get_goods_info(self, goods_id):
        return requests.get(self.url_goods.format(goods_id))
